<%@ page language="java" isELIgnored="false" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ page import="com.tistory.admin.adminmgr.auth.model.AdminAuthSession" %>
<%@ page import="com.tistory.admin.adminmgr.auth.model.AdminAuthMgr" %>
<%@ page import="com.tistory.admin.adminmgr.auth.model.AdminMember"%>
<%@ page import="com.tistory.admin.common.Constants" %>
<%@ page import="org.apache.log4j.Logger"%>
<%@ page import="java.util.*" %>

<%
	Logger log = Logger.getLogger("com.omp.admin.adminmgr.auth.adminLeftMenu");
	AdminAuthSession adminSes = (AdminAuthSession)request.getSession().getAttribute(Constants.ADMIN_AUTH_SESSION_KEY);
    AdminMember adminMem = (AdminMember)adminSes.getAdminMember();
	//String topMenuCode = request.getParameter("topCode");   // 불필요

	//application 의 값을 사용.
	String topMenuCode = (String)session.getAttribute("topMenuCode");
%>

<p class="head_info">
	관리자 <strong><a href="${pageContext.request.contextPath}/main/main.omp"><%=adminMem.getName()%></a></strong>님 최종 접속일 : <%=adminMem.getLstAccDts() %>
	<a href="${pageContext.request.contextPath}/adminMember/adminLogOut.omp"><img src="${pageContext.request.contextPath}/images/btn_logout.gif" alt="" /></a>
</p>

<div class="menu_area">
		<table>
			<tr>
				<td class="vat">
					<h1 class="sub_title"><img src="${pageContext.request.contextPath}/images/sub_logo.gif" alt="" /></h1>
				</td>
				<td class="vat">
					<div class="menu_list">
						<ul class="menu">


<%


	if(adminSes != null &&  topMenuCode !=null){
	    
	
		Map map = adminSes.getMenuListMap();
		
		List depth2List = (List)map.get("ROOT");
		for(int k=0;k<depth2List.size();k++){
		    
		    AdminAuthMgr authMgr2 = (AdminAuthMgr)depth2List.get(k);
		    
		    String menuName = authMgr2.getMenuName();
		    String menuCode = authMgr2.getMenuId();
		    String url          = "";
		    String leftMenuCode = "";
		    String lastUrl      = "";
		
		    List depth3list = (List)map.get(menuCode);
		    
		    if(depth3list.size()>0){
		        AdminAuthMgr authMgr3 = (AdminAuthMgr)depth3list.get(0);
		        String menuCode3 = authMgr3.getMenuId();
		        
		        List depth4list = (List)map.get(menuCode3);
		        
		        if(depth4list.size()>0){
		            AdminAuthMgr authMgr4 = (AdminAuthMgr)depth4list.get(0);
		            
		            url = authMgr4.getPageUrl();
		            leftMenuCode = authMgr4.getMenuId();
		        }
		    }
		    
	                          
            if(url!=null && url.length()>0){
                if(url.indexOf("?") > 0){
                    StringBuffer urlBuf = new StringBuffer();
                    urlBuf.append(url).append("&topCode=").append(menuCode);
                    urlBuf.append("&leftCode=").append(leftMenuCode);
                    lastUrl = urlBuf.toString(); 
                }else{
                    StringBuffer urlBuf = new StringBuffer();
                    urlBuf.append(url).append("?topCode=").append(menuCode);
                    urlBuf.append("&leftCode=").append(leftMenuCode);
                    lastUrl = urlBuf.toString(); 
                }
            }
                    
		                          
		                          
		    if(topMenuCode.equals(authMgr2.getMenuId())){
		    	out.println( "<li><a href='" + lastUrl +"' style='color: #555555'>" + menuName +"</a></li> ");
		    }else{
		        out.println( "<li><a href='" + lastUrl +"'>" + menuName +"</a></li> ");
		    }
		}
    }
		
		



///////////////////////////////////
////////////////////////////////////


 
%>		

					</ul>
				
			</td>
		</tr>
	</table>
	</div><!-- menu_list -->		
</div><!-- menu_area -->

